package com.hnust.controller.paper.paperManagement;

import com.hnust.fx.FXMLController;
import com.hnust.store.DataStore;
import com.hnust.store.PaperListDataStore;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.AnchorPane;
import org.springframework.beans.factory.annotation.Autowired;

import java.net.URL;
import java.util.ResourceBundle;

@FXMLController
public class PaperResultController implements Initializable {

    @FXML
    public ScrollPane container;
    @FXML
    public AnchorPane contain;
    @Override
    public void initialize(URL location, ResourceBundle resources) {
        listenChange();
    }
    public void listenChange(){
        //通过监听最外层容器的宽度，来改变内层Anchor的宽度
        container.widthProperty().addListener(new ChangeListener<Number>() {
            @Override
            public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                contain.setPrefWidth((double)newValue-2);
            }
        });
        //通过监听最外层容器的高度，来改变内层Anchor的高度
        container.heightProperty().addListener(new ChangeListener<Number>() {
            @Override
            public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                contain.setPrefHeight((double)newValue-2);
            }
        });
//        //设置线条的长度
//        contain_process.widthProperty().addListener(new ChangeListener<Number>() {
//            @Override
//            public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
//                line1.setPrefWidth((double)newValue*0.15);
//                line2.setPrefWidth((double)newValue*0.15);
//            }
//        });
    }



}
